﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Model;
using System.Data.SqlClient;
using System.IO;
using HT.DBUtility;

namespace HT.DAL
{
    public class Dal_Basic
    {
        #region 打印机管理 基本信息设置
        public int AddPrintList(string name, int num, int type)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into printList(p_name,p_value,P_Type ) values('" + name + "'," + num + "," + type + ")");
            int ss = SQLHelper.ExecuteSql(strSql.ToString());
            return ss;
        }
        public bool isExistPrint(string name)
        {
            bool isExist = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from printList where p_name='" + name + "'");
            DataTable dt = SQLHelper.ExecuteDt(strSql.ToString());

            if (dt != null && dt.Rows.Count > 0)
            {
                isExist = true;
            }

            return isExist;
        }
        public int UpdatePrintList(string name, int num, int type)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update printList set p_value=" + num + ",P_Type=" + type + " where p_name='" + name + "'");
            int ss = SQLHelper.ExecuteSql(strSql.ToString());
            return ss;
        }
        public int DeletePrintList(string name)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete printList where p_name='" + name + "'");
            int ss = SQLHelper.ExecuteSql(strSql.ToString());
            return ss;
        }
        public DataTable GetPrintList()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select p_name 名称,p_value 次数,P_Type from printList");
            DataTable dt = SQLHelper.ExecuteDt(strSql.ToString());
            return dt;
        }
        #endregion

        public DataTable GetData(string tablename, string strWhere)
        {
            string sql = "select *from " + tablename + strWhere;
            return SQLHelper.ExecuteDt(sql);
        }

        public DataTable GetData(string tablename, string strWhere, string fileds)
        {
            string sql = "select " + fileds + " from " + tablename + strWhere;
            return SQLHelper.ExecuteDt(sql);
        }

        public DataTable GetData(string sql)
        {
            return SQLHelper.ExecuteDt(sql);
        }

        /// <summary>
        /// 从 条件表中获取信息
        /// </summary>
        /// <param name="content">查询内容</param>
        /// <param name="tableName">表名</param>
        /// <param name="condition">条件(含 where 部分)</param>
        /// <returns></returns>
        public string GetDataByFiled(string content, string tableName, string condition)
        {
            StringBuilder strSql = new StringBuilder();
            string name = "";
            strSql.Append("select " + content + "  from  " + tableName + condition);


            m_CreateErrorLogTxt("GetDataByFiled", "1", strSql.ToString());


            object obj = SQLHelper.GetSingle(strSql.ToString());

            if (obj != null)
            {
                name = obj.ToString();
            }

            return name;
        }

        public string GetObjData(string sql)
        {
            object obj = SQLHelper.GetSingle(sql);
            return obj.ToString();
        }

        public DataTable GetpfdHData(int pageSize, int pageIndex, ref int count)
        {
            StringBuilder strSql = new StringBuilder();
            int oldPage = (pageIndex - 1) * pageSize;
            strSql.Append("select top " + pageSize + " * from xskdh  where   djstate is null or djstate=0  order by djlsh desc ");

            DataTable dt = SQLHelper.ExecuteDt(strSql.ToString());

            if (dt != null && dt.Rows.Count > 0)
            {
                count += dt.Rows.Count;
                return dt;


            }
            else
                return null;
            //return dt;
        }
        public int GetpfdHCount(string strWhere)
        {
            int count = 0;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(*) yw_pfdH " + strWhere);
            object ss = SQLHelper.GetSingle(strSql.ToString());

            if (ss != null && ss.ToString() != "")
            {
                count = int.Parse(ss.ToString());
            }

            return count;
        }
        /// <summary>
        /// 得到一个对象实体(xskdh)
        /// </summary>
        /// <returns></returns>
        public xskdh GetXskdhModel(string xsdh)
        {
            //该表无主键信息，请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,rq,sj,djzt,xsdh,Bmbh,Bmmc,yyybh,yyymc,khbh,khmc,hyk,hykxf,slhj,jehj,xj,zrje,bqjf,Zjf,bz,djyh,djsj,xgyh,xgsj,cszt,yl from xskdh ");
            strSql.Append(" where xsdh='" + xsdh + "'");

            xskdh model = new xskdh();

            DataTable dt = SQLHelper.ExecuteDt(strSql.ToString());
            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["DjLsh"] != null && dt.Rows[0]["DjLsh"].ToString() != "")
                {
                    model.DjLsh = int.Parse(dt.Rows[0]["DjLsh"].ToString());
                }
                if (dt.Rows[0]["DjBtZdh"] != null && dt.Rows[0]["DjBtZdh"].ToString() != "")
                {
                    model.DjBtZdh = int.Parse(dt.Rows[0]["DjBtZdh"].ToString());
                }
                if (dt.Rows[0]["DjFtZdh"] != null && dt.Rows[0]["DjFtZdh"].ToString() != "")
                {
                    model.DjFtZdh = int.Parse(dt.Rows[0]["DjFtZdh"].ToString());
                }
                if (dt.Rows[0]["DjStZdh"] != null && dt.Rows[0]["DjStZdh"].ToString() != "")
                {
                    model.DjStZdh = int.Parse(dt.Rows[0]["DjStZdh"].ToString());
                }
                if (dt.Rows[0]["DjState"] != null && dt.Rows[0]["DjState"].ToString() != "")
                {
                    model.DjState = dt.Rows[0]["DjState"].ToString();
                }
                if (dt.Rows[0]["DjCount"] != null && dt.Rows[0]["DjCount"].ToString() != "")
                {
                    model.DjCount = int.Parse(dt.Rows[0]["DjCount"].ToString());
                }
                model.rq = dt.Rows[0]["rq"].ToString();
                model.sj = dt.Rows[0]["sj"].ToString();
                if (dt.Rows[0]["djzt"] != null && dt.Rows[0]["djzt"].ToString() != "")
                {
                    model.djzt = dt.Rows[0]["djzt"].ToString();
                }
                if (dt.Rows[0]["xsdh"] != null && dt.Rows[0]["xsdh"].ToString() != "")
                {
                    model.xsdh = dt.Rows[0]["xsdh"].ToString();
                }
                if (dt.Rows[0]["Bmbh"] != null && dt.Rows[0]["Bmbh"].ToString() != "")
                {
                    model.Bmbh = dt.Rows[0]["Bmbh"].ToString();
                }
                if (dt.Rows[0]["Bmmc"] != null && dt.Rows[0]["Bmmc"].ToString() != "")
                {
                    model.Bmmc = dt.Rows[0]["Bmmc"].ToString();
                }
                if (dt.Rows[0]["yyybh"] != null && dt.Rows[0]["yyybh"].ToString() != "")
                {
                    model.yyybh = dt.Rows[0]["yyybh"].ToString();
                }
                if (dt.Rows[0]["yyymc"] != null && dt.Rows[0]["yyymc"].ToString() != "")
                {
                    model.yyymc = dt.Rows[0]["yyymc"].ToString();
                }
                if (dt.Rows[0]["khbh"] != null && dt.Rows[0]["khbh"].ToString() != "")
                {
                    model.khbh = dt.Rows[0]["khbh"].ToString();
                }
                if (dt.Rows[0]["khmc"] != null && dt.Rows[0]["khmc"].ToString() != "")
                {
                    model.khmc = dt.Rows[0]["khmc"].ToString();
                }
                if (dt.Rows[0]["hyk"] != null && dt.Rows[0]["hyk"].ToString() != "")
                {
                    model.hyk = dt.Rows[0]["hyk"].ToString();
                }
                if (dt.Rows[0]["hykxf"] != null && dt.Rows[0]["hykxf"].ToString() != "")
                {
                    model.hykxf = decimal.Parse(dt.Rows[0]["hykxf"].ToString());
                }
                if (dt.Rows[0]["slhj"] != null && dt.Rows[0]["slhj"].ToString() != "")
                {
                    model.slhj = decimal.Parse(dt.Rows[0]["slhj"].ToString());
                }
                if (dt.Rows[0]["jehj"] != null && dt.Rows[0]["jehj"].ToString() != "")
                {
                    model.jehj = decimal.Parse(dt.Rows[0]["jehj"].ToString());
                }
                if (dt.Rows[0]["xj"] != null && dt.Rows[0]["xj"].ToString() != "")
                {
                    model.xj = decimal.Parse(dt.Rows[0]["xj"].ToString());
                }
                if (dt.Rows[0]["zrje"] != null && dt.Rows[0]["zrje"].ToString() != "")
                {
                    model.zrje = decimal.Parse(dt.Rows[0]["zrje"].ToString());
                }
                if (dt.Rows[0]["bqjf"] != null && dt.Rows[0]["bqjf"].ToString() != "")
                {
                    model.bqjf = decimal.Parse(dt.Rows[0]["bqjf"].ToString());
                }
                if (dt.Rows[0]["Zjf"] != null && dt.Rows[0]["Zjf"].ToString() != "")
                {
                    model.Zjf = decimal.Parse(dt.Rows[0]["Zjf"].ToString());
                }
                if (dt.Rows[0]["bz"] != null && dt.Rows[0]["bz"].ToString() != "")
                {
                    model.bz = dt.Rows[0]["bz"].ToString();
                }
                if (dt.Rows[0]["djyh"] != null && dt.Rows[0]["djyh"].ToString() != "")
                {
                    model.djyh = dt.Rows[0]["djyh"].ToString();
                }
                if (dt.Rows[0]["djsj"] != null && dt.Rows[0]["djsj"].ToString() != "")
                {
                    model.djsj = DateTime.Parse(dt.Rows[0]["djsj"].ToString());
                }
                if (dt.Rows[0]["xgyh"] != null && dt.Rows[0]["xgyh"].ToString() != "")
                {
                    model.xgyh = dt.Rows[0]["xgyh"].ToString();
                }
                if (dt.Rows[0]["xgsj"] != null && dt.Rows[0]["xgsj"].ToString() != "")
                {
                    model.xgsj = DateTime.Parse(dt.Rows[0]["xgsj"].ToString());
                }
                if (dt.Rows[0]["cszt"] != null && dt.Rows[0]["cszt"].ToString() != "")
                {
                    model.cszt = int.Parse(dt.Rows[0]["cszt"].ToString());
                }
                if (dt.Rows[0]["yl"] != null && dt.Rows[0]["yl"].ToString() != "")
                {
                    model.yl = decimal.Parse(dt.Rows[0]["yl"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary> 
  		/// 将数据集(DataTable)转换 对象 xskdh_Entity
  		/// 创建人：minjie 
  		/// 创建时间:2018-06-28 10:45:35 
  		/// </summary> 
  		public xskdh GetXskdhEntity(DataRow dr)
        {
            xskdh model = new xskdh();

            if (dr != null)
            {
                if (dr["DjLsh"] != null && dr["DjLsh"].ToString() != "")
                {
                    model.DjLsh = int.Parse(dr["DjLsh"].ToString());
                }
                if (dr["DjBtZdh"] != null && dr["DjBtZdh"].ToString() != "")
                {
                    model.DjBtZdh = int.Parse(dr["DjBtZdh"].ToString());
                }
                if (dr["DjFtZdh"] != null && dr["DjFtZdh"].ToString() != "")
                {
                    model.DjFtZdh = int.Parse(dr["DjFtZdh"].ToString());
                }
                if (dr["DjStZdh"] != null && dr["DjStZdh"].ToString() != "")
                {
                    model.DjStZdh = int.Parse(dr["DjStZdh"].ToString());
                }
                model.DjState = dr["DjState"].ToString();
                if (dr["DjCount"] != null && dr["DjCount"].ToString() != "")
                {
                    model.DjCount = int.Parse(dr["DjCount"].ToString());
                }
                if (dr["rq"] != null && dr["rq"].ToString() != "")
                {
                    model.rq = dr["rq"].ToString();
                }
                if (dr["sj"] != null && dr["sj"].ToString() != "")
                {
                    model.sj = dr["sj"].ToString();
                }
                model.djzt = dr["djzt"].ToString();
                model.xsdh = dr["xsdh"].ToString();
                model.Bmbh = dr["Bmbh"].ToString();
                model.Bmmc = dr["Bmmc"].ToString();
                model.yyybh = dr["yyybh"].ToString();
                model.yyymc = dr["yyymc"].ToString();
                model.khbh = dr["khbh"].ToString();
                model.khmc = dr["khmc"].ToString();
                model.hyk = dr["hyk"].ToString();
                if (dr["hykxf"] != null && dr["hykxf"].ToString() != "")
                {
                    model.hykxf = decimal.Parse(dr["hykxf"].ToString());
                }
                if (dr["slhj"] != null && dr["slhj"].ToString() != "")
                {
                    model.slhj = decimal.Parse(dr["slhj"].ToString());
                }
                if (dr["jehj"] != null && dr["jehj"].ToString() != "")
                {
                    model.jehj = decimal.Parse(dr["jehj"].ToString());
                }
                if (dr["xj"] != null && dr["xj"].ToString() != "")
                {
                    model.xj = decimal.Parse(dr["xj"].ToString());
                }
                if (dr["zrje"] != null && dr["zrje"].ToString() != "")
                {
                    model.zrje = decimal.Parse(dr["zrje"].ToString());
                }
                if (dr["bqjf"] != null && dr["bqjf"].ToString() != "")
                {
                    model.bqjf = decimal.Parse(dr["bqjf"].ToString());
                }
                if (dr["Zjf"] != null && dr["Zjf"].ToString() != "")
                {
                    model.Zjf = decimal.Parse(dr["Zjf"].ToString());
                }
                model.bz = dr["bz"].ToString();
                model.djyh = dr["djyh"].ToString();
                if (dr["djsj"] != null && dr["djsj"].ToString() != "")
                {
                    model.djsj = DateTime.Parse(dr["djsj"].ToString());
                }
                model.xgyh = dr["xgyh"].ToString();
                if (dr["xgsj"] != null && dr["xgsj"].ToString() != "")
                {
                    model.xgsj = DateTime.Parse(dr["xgsj"].ToString());
                }
                if (dr["cszt"] != null && dr["cszt"].ToString() != "")
                {
                    model.cszt = int.Parse(dr["cszt"].ToString());
                }
                if (dr["yl"] != null && dr["yl"].ToString() != "")
                {
                    model.yl = decimal.Parse(dr["yl"].ToString());
                }
                if (dr["SalesStatus"] != null && dr["SalesStatus"].ToString() != "")
                {
                    model.SalesStatus = int.Parse(dr["SalesStatus"].ToString());
                }
                model.Syybh = dr["Syybh"].ToString();
                model.Syymc = dr["Syymc"].ToString();

                if (dr["ssjehj"] != null && dr["ssjehj"].ToString() != "")
                {
                    model.ssjehj = decimal.Parse(dr["ssjehj"].ToString());
                }
                if (dr["wx"] != null && dr["wx"].ToString() != "")
                {
                    model.wx = decimal.Parse(dr["wx"].ToString());
                }
                if (dr["zfb"] != null && dr["zfb"].ToString() != "")
                {
                    model.zfb = decimal.Parse(dr["zfb"].ToString());
                }
                if (dr["djq"] != null && dr["djq"].ToString() != "")
                {
                    model.djq = decimal.Parse(dr["djq"].ToString());
                }
                if (dr["yhk"] != null && dr["yhk"].ToString() != "")
                {
                    model.yhk = decimal.Parse(dr["yhk"].ToString());
                }
                return model;

            }
            else
            {
                return null;
            }
        }


        public DataSet GetxskdBDataDs(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select DjLsh,DjBth,hh,tmh,spbh,spmc,gg,dw,sl,Dj,pfj,hyzk,hyyh,zyhjg,kcsl,je,hxsdh,yyy,jj,ysbh,ysmc,cm from  dbo.xskdb  " + strWhere);
            DataSet ds = SQLHelper.ExecuteDs(strSql.ToString());
            return ds;
        }
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <returns></returns>
        public int UpdatexskdhStatus(DataTable dt)
        {
            List<string> sqlList = new List<string>();
            foreach (DataRow dr in dt.Rows)
            {
                sqlList.Add("update xskdh set djstate=1 where  xsdh='" + dr["xsdh"].ToString() + "'");
            }
            int ss = UpdateXskdData(sqlList);
            return ss;
        }
        /// <summary>
        /// 保存销售单
        /// </summary>
        /// <param name="sqlList"></param>
        /// <returns></returns>
        public int UpdateXskdData(List<string> sqlList)
        {

            int s1 = SQLHelper.ExecuteSqlTran(sqlList);
            return s1;
        }
        public SpdaHModel GetspdaHModel(DataRow dr)
        {
            //该表无主键信息，请自定义主键/条件字段

            SpdaHModel model = new SpdaHModel();
            if (dr != null)
            {
                if (dr["DjLsh"] != null && dr["DjLsh"].ToString() != "")
                {
                    model.DjLsh = int.Parse(dr["DjLsh"].ToString());
                }
                if (dr["DjBtZdh"] != null && dr["DjBtZdh"].ToString() != "")
                {
                    model.DjBtZdh = int.Parse(dr["DjBtZdh"].ToString());
                }
                else
                    model.DjBtZdh = 0;
                if (dr["DjFtZdh"] != null && dr["DjFtZdh"].ToString() != "")
                {
                    model.DjFtZdh = int.Parse(dr["DjFtZdh"].ToString());
                }
                else
                    model.DjFtZdh = 0;
                if (dr["DjStZdh"] != null && dr["DjStZdh"].ToString() != "")
                {
                    model.DjStZdh = int.Parse(dr["DjStZdh"].ToString());
                }
                else
                    model.DjStZdh = 0;
                if (dr["DjState"] != null && dr["DjState"].ToString() != "")
                {
                    model.DjState = dr["DjState"].ToString();
                }
                else
                    model.DjState = "";
                if (dr["DjCount"] != null && dr["DjCount"].ToString() != "")
                {
                    model.DjCount = int.Parse(dr["DjCount"].ToString());
                }
                else

                    model.DjCount = 0;
                if (dr["bhfs"] != null && dr["bhfs"].ToString() != "")
                {
                    model.bhfs = dr["bhfs"].ToString();
                }
                else
                    model.bhfs = "";
                if (dr["djcl"] != null && dr["djcl"].ToString() != "")
                {
                    model.djcl = dr["djcl"].ToString();
                }
                else
                    model.djcl = "";
                if (dr["lsh"] != null && dr["lsh"].ToString() != "")
                {
                    model.lsh = int.Parse(dr["lsh"].ToString());
                }
                else
                    model.lsh = 0;
                if (dr["rq"] != null && dr["rq"].ToString() != "")
                {
                    model.rq = dr["rq"].ToString();
                }
                else
                    model.rq = "";
                if (dr["dlbh"] != null && dr["dlbh"].ToString() != "")
                {
                    model.dlbh = dr["dlbh"].ToString();
                }
                else
                    model.dlbh = "";
                if (dr["dlmc"] != null && dr["dlmc"].ToString() != "")
                {
                    model.dlmc = dr["dlmc"].ToString();
                }
                else
                    model.dlmc = "";
                if (dr["xlbh"] != null && dr["xlbh"].ToString() != "")
                {
                    model.xlbh = dr["xlbh"].ToString();
                }
                else
                    model.xlbh = "";
                if (dr["xlmc"] != null && dr["xlmc"].ToString() != "")
                {
                    model.xlmc = dr["xlmc"].ToString();
                }
                else
                    model.xlmc = "";
                if (dr["gysbh"] != null && dr["gysbh"].ToString() != "")
                {
                    model.gysbh = dr["gysbh"].ToString();
                }
                else
                    model.gysbh = "";
                if (dr["Gysmc"] != null && dr["Gysmc"].ToString() != "")
                {
                    model.Gysmc = dr["Gysmc"].ToString();
                }
                else
                    model.Gysmc = "";
                if (dr["cjhh"] != null && dr["cjhh"].ToString() != "")
                {
                    model.cjhh = dr["cjhh"].ToString();
                }
                else
                    model.cjhh = "";
                if (dr["spbh"] != null && dr["spbh"].ToString() != "")
                {
                    model.spbh = dr["spbh"].ToString();
                }
                else
                    model.spbh = "";
                if (dr["tmh"] != null && dr["tmh"].ToString() != "")
                {
                    model.tmh = dr["tmh"].ToString();
                }
                else
                    model.tmh = "";
                if (dr["spmc"] != null && dr["spmc"].ToString() != "")
                {
                    model.spmc = dr["spmc"].ToString();
                }
                else
                    model.spmc = "";
                if (dr["gg"] != null && dr["gg"].ToString() != "")
                {
                    model.gg = dr["gg"].ToString();
                }
                else
                    model.gg = "";
                if (dr["ysbh"] != null && dr["ysbh"].ToString() != "")
                {
                    model.ysbh = dr["ysbh"].ToString();
                }
                else
                    model.ysbh = "";
                if (dr["ysmc"] != null && dr["ysmc"].ToString() != "")
                {
                    model.ysmc = dr["ysmc"].ToString();
                }
                else
                    model.ysmc = "";
                if (dr["cm"] != null && dr["cm"].ToString() != "")
                {
                    model.cm = dr["cm"].ToString();
                }
                else
                    model.cm = "";
                if (dr["Pyjm"] != null && dr["Pyjm"].ToString() != "")
                {
                    model.Pyjm = dr["Pyjm"].ToString();
                }
                else
                    model.Pyjm = "";
                if (dr["ddw"] != null && dr["ddw"].ToString() != "")
                {
                    model.ddw = dr["ddw"].ToString();
                }
                else
                    model.ddw = "";
                if (dr["xdw"] != null && dr["xdw"].ToString() != "")
                {
                    model.xdw = dr["xdw"].ToString();
                }
                else
                    model.xdw = "";
                if (dr["dwhsz"] != null && dr["dwhsz"].ToString() != "")
                {
                    model.dwhsz = decimal.Parse(dr["dwhsz"].ToString());
                }
                else
                    model.dwhsz = 0;
                if (dr["jj"] != null && dr["jj"].ToString() != "")
                {
                    model.jj = decimal.Parse(dr["jj"].ToString());
                }
                else
                    model.jj = 0;
                if (dr["Lsj_Jsz"] != null && dr["Lsj_Jsz"].ToString() != "")
                {
                    model.Lsj_Jsz = decimal.Parse(dr["Lsj_Jsz"].ToString());
                }
                else
                    model.Lsj_Jsz = 0;
                if (dr["Lsj_Csxs"] != null && dr["Lsj_Csxs"].ToString() != "")
                {
                    model.Lsj_Csxs = decimal.Parse(dr["Lsj_Csxs"].ToString());
                }
                else
                    model.Lsj_Csxs = 0;
                if (dr["pfj_Jsz"] != null && dr["pfj_Jsz"].ToString() != "")
                {
                    model.pfj_Jsz = decimal.Parse(dr["pfj_Jsz"].ToString());
                }
                else
                    model.pfj_Jsz = 0;
                if (dr["pfj_Csxs"] != null && dr["pfj_Csxs"].ToString() != "")
                {
                    model.pfj_Csxs = decimal.Parse(dr["pfj_Csxs"].ToString());
                }
                else
                    model.pfj_Csxs = 0;
                if (dr["pfj"] != null && dr["pfj"].ToString() != "")
                {
                    model.pfj = decimal.Parse(dr["pfj"].ToString());
                }
                else
                    model.pfj = 0;
                if (dr["Jmlsj"] != null && dr["Jmlsj"].ToString() != "")
                {
                    model.Jmlsj = decimal.Parse(dr["Jmlsj"].ToString());
                }
                else
                    model.Jmlsj = 0;
                if (dr["pfzk"] != null && dr["pfzk"].ToString() != "")
                {
                    model.pfzk = decimal.Parse(dr["pfzk"].ToString());
                }
                else
                    model.pfzk = 0;
                if (dr["Hyzz"] != null && dr["Hyzz"].ToString() != "")
                {
                    model.Hyzz = decimal.Parse(dr["Hyzz"].ToString());
                }
                else
                    model.Hyzz = 0;
                if (dr["Hyyh"] != null && dr["Hyyh"].ToString() != "")
                {
                    model.Hyyh = decimal.Parse(dr["Hyyh"].ToString());
                }
                else
                    model.Hyyh = 0;
                if (dr["tp"] != null && dr["tp"].ToString() != "")
                {
                    model.tp = (byte[])dr["tp"];
                }
                else
                {
                    byte[] byteArray = System.Text.Encoding.Default.GetBytes("");
                    model.tp = byteArray;
                }

                if (dr["spzt"] != null && dr["spzt"].ToString() != "")
                {
                    model.spzt = dr["spzt"].ToString();
                }
                else
                    model.spzt = "";
                if (dr["qdpl"] != null && dr["qdpl"].ToString() != "")
                {
                    model.qdpl = int.Parse(dr["qdpl"].ToString());
                }
                else
                    model.qdpl = 0;
                if (dr["Ccrq"] != null && dr["Ccrq"].ToString() != "")
                {
                    model.Ccrq = DateTime.Parse(dr["Ccrq"].ToString());
                }
                else
                    model.Ccrq = Convert.ToDateTime("1901-01-01");
                if (dr["bzq"] != null && dr["bzq"].ToString() != "")
                {
                    model.bzq = int.Parse(dr["bzq"].ToString());
                }
                else
                    model.bzq = 0;
                if (dr["tqyjts"] != null && dr["tqyjts"].ToString() != "")
                {
                    model.tqyjts = int.Parse(dr["tqyjts"].ToString());
                }
                else
                    model.tqyjts = 0;
                if (dr["zdkc"] != null && dr["zdkc"].ToString() != "")
                {
                    model.zdkc = int.Parse(dr["zdkc"].ToString());
                }
                else
                    model.zdkc = 0;
                if (dr["zxkc"] != null && dr["zxkc"].ToString() != "")
                {
                    model.zxkc = int.Parse(dr["zxkc"].ToString());
                }
                else
                    model.zxkc = 0;

                if (dr["zjhl"] != null && dr["zjhl"].ToString() != "")
                {
                    model.zjhl = int.Parse(dr["zjhl"].ToString());
                }
                else
                    model.zjhl = 0;
                if (dr["bz"] != null && dr["bz"].ToString() != "")
                {
                    model.bz = dr["bz"].ToString();
                }
                else
                    model.bz = "";
                if (dr["zhjhsj"] != null && dr["zhjhsj"].ToString() != "")
                {
                    model.zhjhsj = DateTime.Parse(dr["zhjhsj"].ToString());
                }
                else
                    model.zhjhsj = Convert.ToDateTime("1901-01-01");
                if (dr["sccgybh"] != null && dr["sccgybh"].ToString() != "")
                {
                    model.sccgybh = dr["sccgybh"].ToString();
                }
                else
                    model.sccgybh = "";
                if (dr["djyh"] != null && dr["djyh"].ToString() != "")
                {
                    model.djyh = dr["djyh"].ToString();
                }
                else
                    model.djyh = "";

                if (dr["djsj"] != null && dr["djsj"].ToString() != "")
                {
                    model.djsj = DateTime.Parse(dr["djsj"].ToString());
                }
                else
                    model.djsj = Convert.ToDateTime("1901-01-01");
                if (dr["xgyh"] != null && dr["xgyh"].ToString() != "")
                {
                    model.xgyh = dr["xgyh"].ToString();
                }
                else
                    model.xgyh = "";
                if (dr["xgsj"] != null && dr["xgsj"].ToString() != "")
                {
                    model.xgsj = DateTime.Parse(dr["xgsj"].ToString());
                }
                else
                    model.xgsj = Convert.ToDateTime("1901-01-01");
                if (dr["cwm"] != null && dr["cwm"].ToString() != "")
                {
                    model.cwm = dr["cwm"].ToString();
                }
                else
                    model.cwm = "";
                if (dr["fhljs"] != null && dr["fhljs"].ToString() != "")
                {
                    model.fhljs = int.Parse(dr["fhljs"].ToString());
                }
                else
                    model.fhljs = 0;
                if (dr["sfdz"] != null && dr["sfdz"].ToString() != "")
                {
                    if ((dr["sfdz"].ToString() == "1") || (dr["sfdz"].ToString().ToLower() == "true"))
                    {
                        model.sfdz = true;
                    }
                    else
                    {
                        model.sfdz = false;
                    }
                }
                else
                    model.sfdz = false;
                if (dr["dysl"] != null && dr["dysl"].ToString() != "")
                {
                    model.dysl = int.Parse(dr["dysl"].ToString());
                }
                else
                {
                    model.dysl = 0;
                }
                if (dr["ydy"] != null && dr["ydy"].ToString() != "")
                {
                    if ((dr["ydy"].ToString() == "1") || (dr["ydy"].ToString().ToLower() == "true"))
                    {
                        model.ydy = true;
                    }
                    else
                    {
                        model.ydy = false;
                    }
                }
                else
                    model.ydy = false;
                if (dr["drlsh"] != null && dr["drlsh"].ToString() != "")
                {
                    model.drlsh = int.Parse(dr["drlsh"].ToString());
                }
                else
                    model.drlsh = 0;
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="spbh"></param>
        /// <returns></returns>
        public bool IsExistSpbh(string spbh)
        {
            bool isExist = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select spbh,spmc from dbo.spdaH   where spbh='" + spbh + "'");
            DataTable dt = SQLHelper.ExecuteDt(strSql.ToString());
            if (dt != null && dt.Rows.Count > 0)
            {
                isExist = true;
            }
            return isExist;
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Updatejbxx_yyydaHModel(yyydaHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update yyydaH set ");
            strSql.Append("DjLsh=@DjLsh,");
            strSql.Append("DjBtZdh=@DjBtZdh,");
            strSql.Append("DjFtZdh=@DjFtZdh,");
            strSql.Append("DjStZdh=@DjStZdh,");
            strSql.Append("DjState=@DjState,");
            strSql.Append("DjCount=@DjCount,");
            //strSql.Append("ygbh=@ygbh,");
            strSql.Append("ymmc=@ymmc,");
            strSql.Append("dmbh=@dmbh,");
            strSql.Append("dmmc=@dmmc,");
            strSql.Append("Ygxb=@Ygxb,");
            strSql.Append("Ygjg=@Ygjg,");
            strSql.Append("xl=@xl,");
            strSql.Append("Ygbz=@Ygbz,");
            strSql.Append("djyh=@djyh,");
            strSql.Append("djsj=@djsj,");
            strSql.Append("xgyh=@xgyh,");
            strSql.Append("xgsj=@xgsj,");
            strSql.Append("mm=@mm,");
            strSql.Append("qxjb=@qxjb,");
            strSql.Append("zdzk=@zdzk");
            strSql.Append(" where ygbh=@ygbh ");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@ygbh", SqlDbType.VarChar,10),
                    new SqlParameter("@ymmc", SqlDbType.VarChar,20),
                    new SqlParameter("@dmbh", SqlDbType.VarChar,10),
                    new SqlParameter("@dmmc", SqlDbType.VarChar,20),
                    new SqlParameter("@Ygxb", SqlDbType.VarChar,10),
                    new SqlParameter("@Ygjg", SqlDbType.VarChar,20),
                    new SqlParameter("@xl", SqlDbType.VarChar,20),
                    new SqlParameter("@Ygbz", SqlDbType.VarChar,20),
                    new SqlParameter("@djyh", SqlDbType.VarChar,10),
                    new SqlParameter("@djsj", SqlDbType.DateTime),
                    new SqlParameter("@xgyh", SqlDbType.VarChar,10),
                    new SqlParameter("@xgsj", SqlDbType.DateTime),
                    new SqlParameter("@mm", SqlDbType.VarChar,20),
                    new SqlParameter("@qxjb", SqlDbType.Int,4),
                    new SqlParameter("@zdzk", SqlDbType.Decimal,9)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.ygbh;
            parameters[7].Value = model.ymmc;
            parameters[8].Value = model.dmbh;
            parameters[9].Value = model.dmmc;
            parameters[10].Value = model.Ygxb;
            parameters[11].Value = model.Ygjg;
            parameters[12].Value = model.xl;
            parameters[13].Value = model.Ygbz;
            parameters[14].Value = model.djyh;
            parameters[15].Value = model.djsj;
            parameters[16].Value = model.xgyh;
            parameters[17].Value = model.xgsj;
            parameters[18].Value = model.mm;
            parameters[19].Value = model.qxjb;
            parameters[20].Value = model.zdzk;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Addjbxx_yyydaHModel(yyydaHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into yyydaH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,ygbh,ymmc,dmbh,dmmc,Ygxb,Ygjg,xl,Ygbz,djyh,djsj,xgyh,xgsj,mm,qxjb,zdzk)");
            strSql.Append(" values (");
            strSql.Append("@DjLsh,@DjBtZdh,@DjFtZdh,@DjStZdh,@DjState,@DjCount,@ygbh,@ymmc,@dmbh,@dmmc,@Ygxb,@Ygjg,@xl,@Ygbz,@djyh,@djsj,@xgyh,@xgsj,@mm,@qxjb,@zdzk)");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@ygbh", SqlDbType.VarChar,10),
                    new SqlParameter("@ymmc", SqlDbType.VarChar,20),
                    new SqlParameter("@dmbh", SqlDbType.VarChar,10),
                    new SqlParameter("@dmmc", SqlDbType.VarChar,20),
                    new SqlParameter("@Ygxb", SqlDbType.VarChar,10),
                    new SqlParameter("@Ygjg", SqlDbType.VarChar,20),
                    new SqlParameter("@xl", SqlDbType.VarChar,20),
                    new SqlParameter("@Ygbz", SqlDbType.VarChar,20),
                    new SqlParameter("@djyh", SqlDbType.VarChar,10),
                    new SqlParameter("@djsj", SqlDbType.DateTime),
                    new SqlParameter("@xgyh", SqlDbType.VarChar,10),
                    new SqlParameter("@xgsj", SqlDbType.DateTime),
                    new SqlParameter("@mm", SqlDbType.VarChar,20),
                    new SqlParameter("@qxjb", SqlDbType.Int,4),
                    new SqlParameter("@zdzk", SqlDbType.Decimal,9)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.ygbh;
            parameters[7].Value = model.ymmc;
            parameters[8].Value = model.dmbh;
            parameters[9].Value = model.dmmc;
            parameters[10].Value = model.Ygxb;
            parameters[11].Value = model.Ygjg;
            parameters[12].Value = model.xl;
            parameters[13].Value = model.Ygbz;
            parameters[14].Value = model.djyh;
            parameters[15].Value = model.djsj;
            parameters[16].Value = model.xgyh;
            parameters[17].Value = model.xgsj;
            parameters[18].Value = model.mm;
            parameters[19].Value = model.qxjb;
            parameters[20].Value = model.zdzk;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HykblHModel GetkhdaHModel(DataRow dr)
        {
            HykblHModel model = new HykblHModel();
            if (dr != null)
            {
                if (dr["DjLsh"] != null && dr["DjLsh"].ToString() != "")
                {
                    model.DjLsh = int.Parse(dr["DjLsh"].ToString());
                }
                if (dr["DjBtZdh"] != null && dr["DjBtZdh"].ToString() != "")
                {
                    model.DjBtZdh = int.Parse(dr["DjBtZdh"].ToString());
                }
                else
                    model.DjBtZdh = 0;
                if (dr["DjFtZdh"] != null && dr["DjFtZdh"].ToString() != "")
                {
                    model.DjFtZdh = int.Parse(dr["DjFtZdh"].ToString());
                }
                else
                    model.DjFtZdh = 0;
                if (dr["DjStZdh"] != null && dr["DjStZdh"].ToString() != "")
                {
                    model.DjStZdh = int.Parse(dr["DjStZdh"].ToString());
                }
                else
                    model.DjStZdh = 0;
                if (dr["DjState"] != null && dr["DjState"].ToString() != "")
                {
                    model.DjState = dr["DjState"].ToString();
                }
                else
                    model.DjState = "";
                if (dr["DjCount"] != null && dr["DjCount"].ToString() != "")
                {
                    model.DjCount = int.Parse(dr["DjCount"].ToString());
                }
                else
                    model.DjCount = 0;
                if (dr["dmbh"] != null && dr["dmbh"].ToString() != "")
                {
                    model.dmbh = dr["dmbh"].ToString();
                }
                else
                    model.dmbh = "";
                if (dr["dmmc"] != null && dr["dmmc"].ToString() != "")
                {
                    model.dmmc = dr["dmmc"].ToString();
                }
                else
                    model.dmmc = "";
                if (dr["khbh"] != null && dr["khbh"].ToString() != "")
                {
                    model.khbh = dr["khbh"].ToString();
                }
                else
                    model.khbh = "";
                if (dr["khmc"] != null && dr["khmc"].ToString() != "")
                {
                    model.khmc = dr["khmc"].ToString();
                }
                else
                    model.khmc = "";
                if (dr["kh"] != null && dr["kh"].ToString() != "")
                {
                    model.kh = dr["kh"].ToString();
                }
                else
                    model.kh = "";
                if (dr["dh"] != null && dr["dh"].ToString() != "")
                {
                    model.dh = dr["dh"].ToString();
                }
                else
                    model.dh = "";
                if (dr["dz"] != null && dr["dz"].ToString() != "")
                {
                    model.dz = dr["dz"].ToString();
                }
                else
                    model.dz = "";
                if (dr["hyzk"] != null && dr["hyzk"].ToString() != "")
                {
                    model.hyzk = decimal.Parse(dr["hyzk"].ToString());
                }
                else
                    model.hyzk = 0;
                if (dr["hykye"] != null && dr["hykye"].ToString() != "")
                {
                    model.hykye = decimal.Parse(dr["hykye"].ToString());
                }
                else
                    model.hykye = 0;
                if (dr["xfzjf"] != null && dr["xfzjf"].ToString() != "")
                {
                    model.xfzjf = decimal.Parse(dr["xfzjf"].ToString());
                }
                else
                    model.xfzjf = 0;
                if (dr["jfye"] != null && dr["jfye"].ToString() != "")
                {
                    model.jfye = decimal.Parse(dr["jfye"].ToString());
                }
                else
                    model.jfye = 0;
                if (dr["zjxfjf"] != null && dr["zjxfjf"].ToString() != "")
                {
                    model.zjxfjf = decimal.Parse(dr["zjxfjf"].ToString());
                }
                else
                    model.zjxfjf = 0;
                if (dr["zjxfsj"] != null && dr["zjxfsj"].ToString() != "")
                {
                    model.zjxfsj = DateTime.Parse(dr["zjxfsj"].ToString());
                }
                else
                    model.zjxfsj = Convert.ToDateTime("1900-01-01");
                if (dr["hykzt"] != null && dr["hykzt"].ToString() != "")
                {
                    model.hykzt = dr["hykzt"].ToString();
                }
                else
                    model.hykzt = "";
                if (dr["sffsdx"] != null && dr["sffsdx"].ToString() != "")
                {
                    if ((dr["sffsdx"].ToString() == "1") || (dr["sffsdx"].ToString().ToLower() == "true"))
                    {
                        model.sffsdx = true;
                    }
                    else
                    {
                        model.sffsdx = false;
                    }
                }
                else
                    model.sffsdx = false;

                if (dr["rq"] != null && dr["rq"].ToString() != "")
                {
                    model.rq = dr["rq"].ToString();
                }
                else
                    model.rq = "1901-01-01";
                if (dr["sj"] != null && dr["sj"].ToString() != "")
                {
                    model.sj = dr["sj"].ToString();
                }
                else
                    model.sj = "1901-01-01";
                if (dr["djyh"] != null && dr["djyh"].ToString() != "")
                {
                    model.djyh = dr["djyh"].ToString();
                }
                else
                {
                    model.djyh = "";
                }
                if (dr["djsj"] != null && dr["djsj"].ToString() != "")
                {
                    model.djsj = DateTime.Parse(dr["djsj"].ToString());
                }
                else
                    model.djsj = Convert.ToDateTime("1901-01-01");
                if (dr["xgyh"] != null && dr["xgyh"].ToString() != "")
                {
                    model.xgyh = dr["xgyh"].ToString();
                }
                else
                    model.xgyh = "";
                if (dr["mm"] != null && dr["mm"].ToString() != "")
                {
                    model.mm = dr["mm"].ToString();
                }
                else
                    model.mm = "";
                if (dr["xgsj"] != null && dr["xgsj"].ToString() != "")
                {
                    model.xgsj = DateTime.Parse(dr["xgsj"].ToString());
                }
                else
                    model.xgsj = Convert.ToDateTime("1901-01-01");
                if (dr["bz"] != null && dr["bz"].ToString() != "")
                {
                    model.bz = dr["bz"].ToString();
                }
                else
                    model.bz = "";
                if (dr["srmm"] != null && dr["srmm"].ToString() != "")
                {
                    model.srmm = dr["srmm"].ToString();
                }
                else
                    model.srmm = "";
                if (dr["cfsrmm"] != null && dr["cfsrmm"].ToString() != "")
                {
                    model.cfsrmm = dr["cfsrmm"].ToString();
                }
                else
                    model.cfsrmm = "";
                if (dr["sfz"] != null && dr["sfz"].ToString() != "")
                {
                    model.sfz = dr["sfz"].ToString();
                }
                else
                    model.sfz = "";
                if (dr["sr"] != null && dr["sr"].ToString() != "")
                {
                    model.sr = DateTime.Parse(dr["sr"].ToString());
                }
                else
                    model.sr = Convert.ToDateTime("1901-01-01");
                if (dr["xb"] != null && dr["xb"].ToString() != "")
                {
                    model.xb = dr["xb"].ToString();
                }
                else
                    model.xb = "";
                if (dr["ykh"] != null && dr["ykh"].ToString() != "")
                {
                    model.ykh = dr["ykh"].ToString();
                }
                else
                    model.ykh = "";
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdatespdaHModel(SpdaHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update spdaH set ");
            strSql.Append("DjLsh=@DjLsh,");
            strSql.Append("DjBtZdh=@DjBtZdh,");
            strSql.Append("DjFtZdh=@DjFtZdh,");
            strSql.Append("DjStZdh=@DjStZdh,");
            strSql.Append("DjState=@DjState,");
            strSql.Append("DjCount=@DjCount,");
            strSql.Append("bhfs=@bhfs,");
            strSql.Append("djcl=@djcl,");
            strSql.Append("lsh=@lsh,");
            strSql.Append("rq=@rq,");
            strSql.Append("dlbh=@dlbh,");
            strSql.Append("dlmc=@dlmc,");
            strSql.Append("xlbh=@xlbh,");
            strSql.Append("xlmc=@xlmc,");
            strSql.Append("gysbh=@gysbh,");
            strSql.Append("Gysmc=@Gysmc,");
            strSql.Append("cjhh=@cjhh,");
            //strSql.Append("spbh=@spbh,");
            strSql.Append("tmh=@tmh,");
            strSql.Append("spmc=@spmc,");
            strSql.Append("gg=@gg,");
            strSql.Append("ysbh=@ysbh,");
            strSql.Append("ysmc=@ysmc,");
            strSql.Append("cm=@cm,");
            strSql.Append("Pyjm=@Pyjm,");
            strSql.Append("ddw=@ddw,");
            strSql.Append("xdw=@xdw,");
            strSql.Append("dwhsz=@dwhsz,");
            strSql.Append("jj=@jj,");
            strSql.Append("Lsj_Jsz=@Lsj_Jsz,");
            strSql.Append("Lsj_Csxs=@Lsj_Csxs,");
            strSql.Append("pfj_Jsz=@pfj_Jsz,");
            strSql.Append("pfj_Csxs=@pfj_Csxs,");
            strSql.Append("pfj=@pfj,");
            strSql.Append("Jmlsj=@Jmlsj,");
            strSql.Append("pfzk=@pfzk,");
            strSql.Append("Hyzz=@Hyzz,");
            strSql.Append("Hyyh=@Hyyh,");
            strSql.Append("tp=@tp,");
            strSql.Append("spzt=@spzt,");
            strSql.Append("qdpl=@qdpl,");
            strSql.Append("Ccrq=@Ccrq,");
            strSql.Append("bzq=@bzq,");
            strSql.Append("tqyjts=@tqyjts,");
            strSql.Append("zdkc=@zdkc,");
            strSql.Append("zxkc=@zxkc,");
            strSql.Append("zjhl=@zjhl,");
            strSql.Append("bz=@bz,");
            strSql.Append("zhjhsj=@zhjhsj,");
            strSql.Append("sccgybh=@sccgybh,");
            strSql.Append("djyh=@djyh,");
            strSql.Append("djsj=@djsj,");
            strSql.Append("xgyh=@xgyh,");
            strSql.Append("xgsj=@xgsj,");
            strSql.Append("cwm=@cwm,");
            strSql.Append("fhljs=@fhljs,");
            strSql.Append("sfdz=@sfdz,");
            strSql.Append("dysl=@dysl,");
            strSql.Append("ydy=@ydy,");
            strSql.Append("drlsh=@drlsh");
            strSql.Append(" where   spbh=@spbh ");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@bhfs", SqlDbType.VarChar,10),
                    new SqlParameter("@djcl", SqlDbType.VarChar,10),
                    new SqlParameter("@lsh", SqlDbType.Int,4),
                    new SqlParameter("@rq", SqlDbType.VarChar,10),
                    new SqlParameter("@dlbh", SqlDbType.VarChar,10),
                    new SqlParameter("@dlmc", SqlDbType.VarChar,20),
                    new SqlParameter("@xlbh", SqlDbType.VarChar,10),
                    new SqlParameter("@xlmc", SqlDbType.VarChar,20),
                    new SqlParameter("@gysbh", SqlDbType.VarChar,10),
                    new SqlParameter("@Gysmc", SqlDbType.VarChar,20),
                    new SqlParameter("@cjhh", SqlDbType.VarChar,20),
                    new SqlParameter("@spbh", SqlDbType.VarChar,20),
                    new SqlParameter("@tmh", SqlDbType.VarChar,20),
                    new SqlParameter("@spmc", SqlDbType.VarChar,50),
                    new SqlParameter("@gg", SqlDbType.VarChar,20),
                    new SqlParameter("@ysbh", SqlDbType.VarChar,10),
                    new SqlParameter("@ysmc", SqlDbType.VarChar,20),
                    new SqlParameter("@cm", SqlDbType.VarChar,20),
                    new SqlParameter("@Pyjm", SqlDbType.VarChar,20),
                    new SqlParameter("@ddw", SqlDbType.VarChar,10),
                    new SqlParameter("@xdw", SqlDbType.VarChar,10),
                    new SqlParameter("@dwhsz", SqlDbType.Decimal,9),
                    new SqlParameter("@jj", SqlDbType.Money,8),
                    new SqlParameter("@Lsj_Jsz", SqlDbType.Decimal,9),
                    new SqlParameter("@Lsj_Csxs", SqlDbType.Decimal,9),
                    new SqlParameter("@pfj_Jsz", SqlDbType.Decimal,9),
                    new SqlParameter("@pfj_Csxs", SqlDbType.Decimal,9),
                    new SqlParameter("@pfj", SqlDbType.Money,8),
                    new SqlParameter("@Jmlsj", SqlDbType.Money,8),
                    new SqlParameter("@pfzk", SqlDbType.Decimal,9),
                    new SqlParameter("@Hyzz", SqlDbType.Decimal,9),
                    new SqlParameter("@Hyyh", SqlDbType.Decimal,9),
                    new SqlParameter("@tp", SqlDbType.Image),
                    new SqlParameter("@spzt", SqlDbType.VarChar,10),
                    new SqlParameter("@qdpl", SqlDbType.Int,4),
                    new SqlParameter("@Ccrq", SqlDbType.DateTime),
                    new SqlParameter("@bzq", SqlDbType.Int,4),
                    new SqlParameter("@tqyjts", SqlDbType.Int,4),
                    new SqlParameter("@zdkc", SqlDbType.Int,4),
                    new SqlParameter("@zxkc", SqlDbType.Int,4),
                    new SqlParameter("@zjhl", SqlDbType.Int,4),
                    new SqlParameter("@bz", SqlDbType.VarChar,100),
                    new SqlParameter("@zhjhsj", SqlDbType.DateTime),
                    new SqlParameter("@sccgybh", SqlDbType.VarChar,10),
                    new SqlParameter("@djyh", SqlDbType.VarChar,10),
                    new SqlParameter("@djsj", SqlDbType.DateTime),
                    new SqlParameter("@xgyh", SqlDbType.VarChar,10),
                    new SqlParameter("@xgsj", SqlDbType.DateTime),
                    new SqlParameter("@cwm", SqlDbType.VarChar,10),
                    new SqlParameter("@fhljs", SqlDbType.Int,4),
                    new SqlParameter("@sfdz", SqlDbType.Bit,1),
                    new SqlParameter("@dysl", SqlDbType.Int,4),
                    new SqlParameter("@ydy", SqlDbType.Bit,1),
                    new SqlParameter("@drlsh", SqlDbType.Int,4)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.bhfs;
            parameters[7].Value = model.djcl;
            parameters[8].Value = model.lsh;
            parameters[9].Value = model.rq;
            parameters[10].Value = model.dlbh;
            parameters[11].Value = model.dlmc;
            parameters[12].Value = model.xlbh;
            parameters[13].Value = model.xlmc;
            parameters[14].Value = model.gysbh;
            parameters[15].Value = model.Gysmc;
            parameters[16].Value = model.cjhh;
            parameters[17].Value = model.spbh;
            parameters[18].Value = model.tmh;
            parameters[19].Value = model.spmc;
            parameters[20].Value = model.gg;
            parameters[21].Value = model.ysbh;
            parameters[22].Value = model.ysmc;
            parameters[23].Value = model.cm;
            parameters[24].Value = model.Pyjm;
            parameters[25].Value = model.ddw;
            parameters[26].Value = model.xdw;
            parameters[27].Value = model.dwhsz;
            parameters[28].Value = model.jj;
            parameters[29].Value = model.Lsj_Jsz;
            parameters[30].Value = model.Lsj_Csxs;
            parameters[31].Value = model.pfj_Jsz;
            parameters[32].Value = model.pfj_Csxs;
            parameters[33].Value = model.pfj;
            parameters[34].Value = model.Jmlsj;
            parameters[35].Value = model.pfzk;
            parameters[36].Value = model.Hyzz;
            parameters[37].Value = model.Hyyh;
            parameters[38].Value = model.tp;
            parameters[39].Value = model.spzt;
            parameters[40].Value = model.qdpl;
            parameters[41].Value = model.Ccrq;
            parameters[42].Value = model.bzq;
            parameters[43].Value = model.tqyjts;
            parameters[44].Value = model.zdkc;
            parameters[45].Value = model.zxkc;
            parameters[46].Value = model.zjhl;
            parameters[47].Value = model.bz;
            parameters[48].Value = model.zhjhsj;
            parameters[49].Value = model.sccgybh;
            parameters[50].Value = model.djyh;
            parameters[51].Value = model.djsj;
            parameters[52].Value = model.xgyh;
            parameters[53].Value = model.xgsj;
            parameters[54].Value = model.cwm;
            parameters[55].Value = model.fhljs;
            parameters[56].Value = model.sfdz;
            parameters[57].Value = model.dysl;
            parameters[58].Value = model.ydy;
            parameters[59].Value = model.drlsh;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool AddspdaHModel(SpdaHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into spdaH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,bhfs,djcl,lsh,rq,dlbh,dlmc,xlbh,xlmc,gysbh,Gysmc,cjhh,spbh,tmh,spmc,gg,ysbh,ysmc,cm,Pyjm,ddw,xdw,dwhsz,jj,Lsj_Jsz,Lsj_Csxs,pfj_Jsz,pfj_Csxs,pfj,Jmlsj,pfzk,Hyzz,Hyyh,tp,spzt,qdpl,Ccrq,bzq,tqyjts,zdkc,zxkc,zjhl,bz,zhjhsj,sccgybh,djyh,djsj,xgyh,xgsj,cwm,fhljs,sfdz,dysl,ydy,drlsh)");
            strSql.Append(" values (");
            strSql.Append("@DjLsh,@DjBtZdh,@DjFtZdh,@DjStZdh,@DjState,@DjCount,@bhfs,@djcl,@lsh,@rq,@dlbh,@dlmc,@xlbh,@xlmc,@gysbh,@Gysmc,@cjhh,@spbh,@tmh,@spmc,@gg,@ysbh,@ysmc,@cm,@Pyjm,@ddw,@xdw,@dwhsz,@jj,@Lsj_Jsz,@Lsj_Csxs,@pfj_Jsz,@pfj_Csxs,@pfj,@Jmlsj,@pfzk,@Hyzz,@Hyyh,@tp,@spzt,@qdpl,@Ccrq,@bzq,@tqyjts,@zdkc,@zxkc,@zjhl,@bz,@zhjhsj,@sccgybh,@djyh,@djsj,@xgyh,@xgsj,@cwm,@fhljs,@sfdz,@dysl,@ydy,@drlsh)");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@bhfs", SqlDbType.VarChar,10),
                    new SqlParameter("@djcl", SqlDbType.VarChar,10),
                    new SqlParameter("@lsh", SqlDbType.Int,4),
                    new SqlParameter("@rq", SqlDbType.VarChar,10),
                    new SqlParameter("@dlbh", SqlDbType.VarChar,10),
                    new SqlParameter("@dlmc", SqlDbType.VarChar,20),
                    new SqlParameter("@xlbh", SqlDbType.VarChar,10),
                    new SqlParameter("@xlmc", SqlDbType.VarChar,20),
                    new SqlParameter("@gysbh", SqlDbType.VarChar,10),
                    new SqlParameter("@Gysmc", SqlDbType.VarChar,20),
                    new SqlParameter("@cjhh", SqlDbType.VarChar,20),
                    new SqlParameter("@spbh", SqlDbType.VarChar,20),
                    new SqlParameter("@tmh", SqlDbType.VarChar,20),
                    new SqlParameter("@spmc", SqlDbType.VarChar,50),
                    new SqlParameter("@gg", SqlDbType.VarChar,20),
                    new SqlParameter("@ysbh", SqlDbType.VarChar,10),
                    new SqlParameter("@ysmc", SqlDbType.VarChar,20),
                    new SqlParameter("@cm", SqlDbType.VarChar,20),
                    new SqlParameter("@Pyjm", SqlDbType.VarChar,20),
                    new SqlParameter("@ddw", SqlDbType.VarChar,10),
                    new SqlParameter("@xdw", SqlDbType.VarChar,10),
                    new SqlParameter("@dwhsz", SqlDbType.Decimal,9),
                    new SqlParameter("@jj", SqlDbType.Money,8),
                    new SqlParameter("@Lsj_Jsz", SqlDbType.Decimal,9),
                    new SqlParameter("@Lsj_Csxs", SqlDbType.Decimal,9),
                    new SqlParameter("@pfj_Jsz", SqlDbType.Decimal,9),
                    new SqlParameter("@pfj_Csxs", SqlDbType.Decimal,9),
                    new SqlParameter("@pfj", SqlDbType.Money,8),
                    new SqlParameter("@Jmlsj", SqlDbType.Money,8),
                    new SqlParameter("@pfzk", SqlDbType.Decimal,9),
                    new SqlParameter("@Hyzz", SqlDbType.Decimal,9),
                    new SqlParameter("@Hyyh", SqlDbType.Decimal,9),
                    new SqlParameter("@tp", SqlDbType.Image),
                    new SqlParameter("@spzt", SqlDbType.VarChar,10),
                    new SqlParameter("@qdpl", SqlDbType.Int,4),
                    new SqlParameter("@Ccrq", SqlDbType.DateTime),
                    new SqlParameter("@bzq", SqlDbType.Int,4),
                    new SqlParameter("@tqyjts", SqlDbType.Int,4),
                    new SqlParameter("@zdkc", SqlDbType.Int,4),
                    new SqlParameter("@zxkc", SqlDbType.Int,4),
                    new SqlParameter("@zjhl", SqlDbType.Int,4),
                    new SqlParameter("@bz", SqlDbType.VarChar,100),
                    new SqlParameter("@zhjhsj", SqlDbType.DateTime),
                    new SqlParameter("@sccgybh", SqlDbType.VarChar,10),
                    new SqlParameter("@djyh", SqlDbType.VarChar,10),
                    new SqlParameter("@djsj", SqlDbType.DateTime),
                    new SqlParameter("@xgyh", SqlDbType.VarChar,10),
                    new SqlParameter("@xgsj", SqlDbType.DateTime),
                    new SqlParameter("@cwm", SqlDbType.VarChar,10),
                    new SqlParameter("@fhljs", SqlDbType.Int,4),
                    new SqlParameter("@sfdz", SqlDbType.Bit,1),
                    new SqlParameter("@dysl", SqlDbType.Int,4),
                    new SqlParameter("@ydy", SqlDbType.Bit,1),
                    new SqlParameter("@drlsh", SqlDbType.Int,4)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.bhfs;
            parameters[7].Value = model.djcl;
            parameters[8].Value = model.lsh;
            parameters[9].Value = model.rq;
            parameters[10].Value = model.dlbh;
            parameters[11].Value = model.dlmc;
            parameters[12].Value = model.xlbh;
            parameters[13].Value = model.xlmc;
            parameters[14].Value = model.gysbh;
            parameters[15].Value = model.Gysmc;
            parameters[16].Value = model.cjhh;
            parameters[17].Value = model.spbh;
            parameters[18].Value = model.tmh;
            parameters[19].Value = model.spmc;
            parameters[20].Value = model.gg;
            parameters[21].Value = model.ysbh;
            parameters[22].Value = model.ysmc;
            parameters[23].Value = model.cm;
            parameters[24].Value = model.Pyjm;
            parameters[25].Value = model.ddw;
            parameters[26].Value = model.xdw;
            parameters[27].Value = model.dwhsz;
            parameters[28].Value = model.jj;
            parameters[29].Value = model.Lsj_Jsz;
            parameters[30].Value = model.Lsj_Csxs;
            parameters[31].Value = model.pfj_Jsz;
            parameters[32].Value = model.pfj_Csxs;
            parameters[33].Value = model.pfj;
            parameters[34].Value = model.Jmlsj;
            parameters[35].Value = model.pfzk;
            parameters[36].Value = model.Hyzz;
            parameters[37].Value = model.Hyyh;
            parameters[38].Value = model.tp;
            parameters[39].Value = model.spzt;
            parameters[40].Value = model.qdpl;
            parameters[41].Value = model.Ccrq;
            parameters[42].Value = model.bzq;
            parameters[43].Value = model.tqyjts;
            parameters[44].Value = model.zdkc;
            parameters[45].Value = model.zxkc;
            parameters[46].Value = model.zjhl;
            parameters[47].Value = model.bz;
            parameters[48].Value = model.zhjhsj;
            parameters[49].Value = model.sccgybh;
            parameters[50].Value = model.djyh;
            parameters[51].Value = model.djsj;
            parameters[52].Value = model.xgyh;
            parameters[53].Value = model.xgsj;
            parameters[54].Value = model.cwm;
            parameters[55].Value = model.fhljs;
            parameters[56].Value = model.sfdz;
            parameters[57].Value = model.dysl;
            parameters[58].Value = model.ydy;
            parameters[59].Value = model.drlsh;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        ///营业员 得到一个对象实体
        /// </summary>
        public yyydaHModel GetyyydaHModel(DataRow dr)
        {
            yyydaHModel model = new yyydaHModel();

            // '(@DjLsh int,@DjBtZdh int,@DjFtZdh int,@DjStZdh int,@DjState char' 需要参数 @DjState，但未提供该参数。


            if (dr != null)
            {




                if (dr["DjLsh"] != null && dr["DjLsh"].ToString() != "")
                {
                    model.DjLsh = int.Parse(dr["DjLsh"].ToString());
                }
                else
                    model.DjLsh = 0;
                if (dr["DjBtZdh"] != null && dr["DjBtZdh"].ToString() != "")
                {
                    model.DjBtZdh = int.Parse(dr["DjBtZdh"].ToString());
                }
                else
                    model.DjBtZdh = 0;
                if (dr["DjFtZdh"] != null && dr["DjFtZdh"].ToString() != "")
                {
                    model.DjFtZdh = int.Parse(dr["DjFtZdh"].ToString());
                }
                else
                    model.DjFtZdh = 0;
                if (dr["DjStZdh"] != null && dr["DjStZdh"].ToString() != "")
                {
                    model.DjStZdh = int.Parse(dr["DjStZdh"].ToString());
                }
                else
                    model.DjStZdh = 0;


                if (dr["DjState"] != null && dr["DjState"].ToString() != "")
                {
                    model.DjState = dr["DjState"].ToString();
                }
                else
                    model.DjState = "";

                if (dr["DjCount"] != null && dr["DjCount"].ToString() != "")
                {
                    model.DjCount = int.Parse(dr["DjCount"].ToString());
                }
                else
                    model.DjCount = 0;
                if (dr["ygbh"] != null && dr["ygbh"].ToString() != "")
                {
                    model.ygbh = dr["ygbh"].ToString();
                }
                else
                    model.ygbh = "";


                if (dr["ymmc"] != null && dr["ymmc"].ToString() != "")
                {
                    model.ymmc = dr["ymmc"].ToString();
                }
                else
                    model.ymmc = "";
                if (dr["dmbh"] != null && dr["dmbh"].ToString() != "")
                {
                    model.dmbh = dr["dmbh"].ToString();
                }
                else
                    model.dmbh = "";
                if (dr["dmmc"] != null && dr["dmmc"].ToString() != "")
                {
                    model.dmmc = dr["dmmc"].ToString();
                }
                else
                    model.dmmc = "";

                if (dr["Ygxb"] != null && dr["Ygxb"].ToString() != "")
                {
                    model.Ygxb = dr["Ygxb"].ToString();
                }
                else
                    model.Ygxb = "";

                if (dr["Ygjg"] != null && dr["Ygjg"].ToString() != "")
                {
                    model.Ygjg = dr["Ygjg"].ToString();
                }
                else
                    model.Ygjg = "";
                if (dr["xl"] != null && dr["xl"].ToString() != "")
                {
                    model.xl = dr["xl"].ToString();
                }
                else
                    model.xl = "";
                if (dr["Ygbz"] != null && dr["Ygbz"].ToString() != "")
                {
                    model.Ygbz = dr["Ygbz"].ToString();
                }
                else
                    model.Ygbz = "";
                if (dr["djyh"] != null && dr["djyh"].ToString() != "")
                {
                    model.djyh = dr["djyh"].ToString();
                }
                else
                    model.djyh = "";
                if (dr["djsj"] != null && dr["djsj"].ToString() != "")
                {
                    model.djsj = DateTime.Parse(dr["djsj"].ToString());
                }
                else
                    model.djyh = "1900-01-01";
                if (dr["xgyh"] != null && dr["xgyh"].ToString() != "")
                {
                    model.xgyh = dr["xgyh"].ToString();
                }
                else
                    model.xgyh = "";
                if (dr["xgsj"] != null && dr["xgsj"].ToString() != "")
                {
                    model.xgsj = DateTime.Parse(dr["xgsj"].ToString());
                }
                else
                    model.xgsj = Convert.ToDateTime("1900-01-01");
                if (dr["mm"] != null && dr["mm"].ToString() != "")
                {
                    model.mm = dr["mm"].ToString();
                }
                else
                    model.mm = "";
                //if (dr["qxjb"] != null && dr["qxjb"].ToString() != "")
                //{
                //    model.qxjb = int.Parse(dr["qxjb"].ToString());
                //}
                //else
                    model.qxjb = 0;
                //if (dr["zdzk"] != null && dr["zdzk"].ToString() != "")
                //{
                //    model.zdzk = decimal.Parse(dr["zdzk"].ToString());
                //}
                //else
                    model.zdzk = 0;
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="spbh"></param>
        /// <returns></returns>
        public bool IsExistYyy(string ygbh)
        {
            bool isExist = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ygbh,dmmc from  yyydaH  where ygbh='" + ygbh + "'");
            DataTable dt = SQLHelper.ExecuteDt(strSql.ToString());
            if (dt != null && dt.Rows.Count > 0)
            {
                isExist = true;
            }
            return isExist;
        }


        /// <summary>
        /// 是否存在 客户信息
        /// </summary>
        /// <param name="spbh"></param>
        /// <returns></returns>
        public bool IsExistKhxx(string khbh)
        {
            bool isExist = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select khbh,khmc from dbo.hykblH  where kh='" + khbh + "'");
            DataTable dt = SQLHelper.ExecuteDt(strSql.ToString());
            if (dt != null && dt.Rows.Count > 0)
            {
                isExist = true;
            }
            return isExist;
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Updatejbxx_khdaH(HykblHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update hykblH set ");
            strSql.Append("DjLsh=@DjLsh,");
            strSql.Append("DjBtZdh=@DjBtZdh,");
            strSql.Append("DjFtZdh=@DjFtZdh,");
            strSql.Append("DjStZdh=@DjStZdh,");
            strSql.Append("DjState=@DjState,");
            strSql.Append("DjCount=@DjCount,");
            strSql.Append("dmbh=@dmbh,");
            strSql.Append("dmmc=@dmmc,");
            strSql.Append("khbh=@khbh,");
            strSql.Append("khmc=@khmc,");
            //strSql.Append("kh=@kh,");
            strSql.Append("dh=@dh,");
            strSql.Append("dz=@dz,");
            strSql.Append("hyzk=@hyzk,");
            strSql.Append("hykye=@hykye,");
            strSql.Append("xfzjf=@xfzjf,");
            strSql.Append("jfye=@jfye,");
            strSql.Append("zjxfjf=@zjxfjf,");
            strSql.Append("zjxfsj=@zjxfsj,");
            strSql.Append("hykzt=@hykzt,");
            strSql.Append("sffsdx=@sffsdx,");
            strSql.Append("rq=@rq,");
            strSql.Append("sj=@sj,");
            strSql.Append("djyh=@djyh,");
            strSql.Append("djsj=@djsj,");
            strSql.Append("xgyh=@xgyh,");
            strSql.Append("mm=@mm,");
            strSql.Append("xgsj=@xgsj,");
            strSql.Append("bz=@bz,");
            strSql.Append("srmm=@srmm,");
            strSql.Append("cfsrmm=@cfsrmm,");
            strSql.Append("sfz=@sfz,");
            strSql.Append("sr=@sr,");
            strSql.Append("xb=@xb,");
            strSql.Append("ykh=@ykh");
            strSql.Append(" where  kh=@kh ");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@dmbh", SqlDbType.VarChar,10),
                    new SqlParameter("@dmmc", SqlDbType.VarChar,20),
                    new SqlParameter("@khbh", SqlDbType.VarChar,10),
                    new SqlParameter("@khmc", SqlDbType.VarChar,30),
                    new SqlParameter("@kh", SqlDbType.VarChar,20),
                    new SqlParameter("@dh", SqlDbType.VarChar,20),
                    new SqlParameter("@dz", SqlDbType.VarChar,50),
                    new SqlParameter("@hyzk", SqlDbType.Decimal,9),
                    new SqlParameter("@hykye", SqlDbType.Decimal,9),
                    new SqlParameter("@xfzjf", SqlDbType.Decimal,9),
                    new SqlParameter("@jfye", SqlDbType.Decimal,9),
                    new SqlParameter("@zjxfjf", SqlDbType.Decimal,9),
                    new SqlParameter("@zjxfsj", SqlDbType.DateTime),
                    new SqlParameter("@hykzt", SqlDbType.VarChar,10),
                    new SqlParameter("@sffsdx", SqlDbType.Bit,1),
                    new SqlParameter("@rq", SqlDbType.DateTime),
                    new SqlParameter("@sj", SqlDbType.DateTime),
                    new SqlParameter("@djyh", SqlDbType.VarChar,10),
                    new SqlParameter("@djsj", SqlDbType.DateTime),
                    new SqlParameter("@xgyh", SqlDbType.VarChar,10),
                    new SqlParameter("@mm", SqlDbType.VarChar,6),
                    new SqlParameter("@xgsj", SqlDbType.DateTime),
                    new SqlParameter("@bz", SqlDbType.VarChar,60),
                    new SqlParameter("@srmm", SqlDbType.VarChar,20),
                    new SqlParameter("@cfsrmm", SqlDbType.VarChar,20),
                    new SqlParameter("@sfz", SqlDbType.VarChar,18),
                    new SqlParameter("@sr", SqlDbType.DateTime),
                    new SqlParameter("@xb", SqlDbType.VarChar,4),
                    new SqlParameter("@ykh", SqlDbType.VarChar,20)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.dmbh;
            parameters[7].Value = model.dmmc;
            parameters[8].Value = model.khbh;
            parameters[9].Value = model.khmc;
            parameters[10].Value = model.kh;
            parameters[11].Value = model.dh;
            parameters[12].Value = model.dz;
            parameters[13].Value = model.hyzk;
            parameters[14].Value = model.hykye;
            parameters[15].Value = model.xfzjf;
            parameters[16].Value = model.jfye;
            parameters[17].Value = model.zjxfjf;
            parameters[18].Value = model.zjxfsj;
            parameters[19].Value = model.hykzt;
            parameters[20].Value = model.sffsdx;
            parameters[21].Value = model.rq;
            parameters[22].Value = model.sj;
            parameters[23].Value = model.djyh;
            parameters[24].Value = model.djsj;
            parameters[25].Value = model.xgyh;
            parameters[26].Value = model.mm;
            parameters[27].Value = model.xgsj;
            parameters[28].Value = model.bz;
            parameters[29].Value = model.srmm;
            parameters[30].Value = model.cfsrmm;
            parameters[31].Value = model.sfz;
            parameters[32].Value = model.sr;
            parameters[33].Value = model.xb;
            parameters[34].Value = model.ykh;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Addjbxx_khdaH(HykblHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into hykblH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,dmbh,dmmc,khbh,khmc,kh,dh,dz,hyzk,hykye,xfzjf,jfye,zjxfjf,zjxfsj,hykzt,sffsdx,rq,sj,djyh,djsj,xgyh,mm,xgsj,bz,srmm,cfsrmm,sfz,sr,xb,ykh)");
            strSql.Append(" values (");
            strSql.Append("@DjLsh,@DjBtZdh,@DjFtZdh,@DjStZdh,@DjState,@DjCount,@dmbh,@dmmc,@khbh,@khmc,@kh,@dh,@dz,@hyzk,@hykye,@xfzjf,@jfye,@zjxfjf,@zjxfsj,@hykzt,@sffsdx,@rq,@sj,@djyh,@djsj,@xgyh,@mm,@xgsj,@bz,@srmm,@cfsrmm,@sfz,@sr,@xb,@ykh)");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@dmbh", SqlDbType.VarChar,10),
                    new SqlParameter("@dmmc", SqlDbType.VarChar,20),
                    new SqlParameter("@khbh", SqlDbType.VarChar,10),
                    new SqlParameter("@khmc", SqlDbType.VarChar,30),
                    new SqlParameter("@kh", SqlDbType.VarChar,20),
                    new SqlParameter("@dh", SqlDbType.VarChar,20),
                    new SqlParameter("@dz", SqlDbType.VarChar,50),
                    new SqlParameter("@hyzk", SqlDbType.Decimal,9),
                    new SqlParameter("@hykye", SqlDbType.Decimal,9),
                    new SqlParameter("@xfzjf", SqlDbType.Decimal,9),
                    new SqlParameter("@jfye", SqlDbType.Decimal,9),
                    new SqlParameter("@zjxfjf", SqlDbType.Decimal,9),
                    new SqlParameter("@zjxfsj", SqlDbType.DateTime),
                    new SqlParameter("@hykzt", SqlDbType.VarChar,10),
                    new SqlParameter("@sffsdx", SqlDbType.Bit,1),
                    new SqlParameter("@rq", SqlDbType.DateTime),
                    new SqlParameter("@sj", SqlDbType.DateTime),
                    new SqlParameter("@djyh", SqlDbType.VarChar,10),
                    new SqlParameter("@djsj", SqlDbType.DateTime),
                    new SqlParameter("@xgyh", SqlDbType.VarChar,10),
                    new SqlParameter("@mm", SqlDbType.VarChar,6),
                    new SqlParameter("@xgsj", SqlDbType.DateTime),
                    new SqlParameter("@bz", SqlDbType.VarChar,60),
                    new SqlParameter("@srmm", SqlDbType.VarChar,20),
                    new SqlParameter("@cfsrmm", SqlDbType.VarChar,20),
                    new SqlParameter("@sfz", SqlDbType.VarChar,18),
                    new SqlParameter("@sr", SqlDbType.DateTime),
                    new SqlParameter("@xb", SqlDbType.VarChar,4),
                    new SqlParameter("@ykh", SqlDbType.VarChar,20)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.dmbh;
            parameters[7].Value = model.dmmc;
            parameters[8].Value = model.khbh;
            parameters[9].Value = model.khmc;
            parameters[10].Value = model.kh;
            parameters[11].Value = model.dh;
            parameters[12].Value = model.dz;
            parameters[13].Value = model.hyzk;
            parameters[14].Value = model.hykye;
            parameters[15].Value = model.xfzjf;
            parameters[16].Value = model.jfye;
            parameters[17].Value = model.zjxfjf;
            parameters[18].Value = model.zjxfsj;
            parameters[19].Value = model.hykzt;
            parameters[20].Value = model.sffsdx;
            parameters[21].Value = model.rq;
            parameters[22].Value = model.sj;
            parameters[23].Value = model.djyh;
            parameters[24].Value = model.djsj;
            parameters[25].Value = model.xgyh;
            parameters[26].Value = model.mm;
            parameters[27].Value = model.xgsj;
            parameters[28].Value = model.bz;
            parameters[29].Value = model.srmm;
            parameters[30].Value = model.cfsrmm;
            parameters[31].Value = model.sfz;
            parameters[32].Value = model.sr;
            parameters[33].Value = model.xb;
            parameters[34].Value = model.ykh;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public dmdaHModel GetdmdaHModel(DataRow dr)
        {
            dmdaHModel model = new dmdaHModel();
            if (dr != null)
            {
                if (dr["DjLsh"] != null && dr["DjLsh"].ToString() != "")
                {
                    model.DjLsh = int.Parse(dr["DjLsh"].ToString());
                }
                if (dr["DjBtZdh"] != null && dr["DjBtZdh"].ToString() != "")
                {
                    model.DjBtZdh = int.Parse(dr["DjBtZdh"].ToString());
                }
                else
                    model.DjBtZdh = 0;
                if (dr["DjFtZdh"] != null && dr["DjFtZdh"].ToString() != "")
                {
                    model.DjFtZdh = int.Parse(dr["DjFtZdh"].ToString());
                }
                else
                    model.DjFtZdh = 0;
                if (dr["DjStZdh"] != null && dr["DjStZdh"].ToString() != "")
                {
                    model.DjStZdh = int.Parse(dr["DjStZdh"].ToString());
                }
                else
                    model.DjStZdh = 0;
                if (dr["DjState"] != null && dr["DjState"].ToString() != "")
                {
                    model.DjState = dr["DjState"].ToString();
                }
                else
                    model.DjState = "";
                if (dr["DjCount"] != null && dr["DjCount"].ToString() != "")
                {
                    model.DjCount = int.Parse(dr["DjCount"].ToString());
                }
                else
                    model.DjCount = 0;
                if (dr["Dmbh"] != null && dr["Dmbh"].ToString() != "")
                {
                    model.Dmbh = dr["Dmbh"].ToString();
                }
                else
                    model.Dmbh = "";
                if (dr["Dmmc"] != null && dr["Dmmc"].ToString() != "")
                {
                    model.Dmmc = dr["Dmmc"].ToString();
                }
                else
                    model.Dmmc = "";
                if (dr["Dmlb"] != null && dr["Dmlb"].ToString() != "")
                {
                    model.Dmlb = dr["Dmlb"].ToString();
                }
                else
                    model.Dmlb = "";
                if (dr["sjqybh"] != null && dr["sjqybh"].ToString() != "")
                {
                    model.sjqybh = dr["sjqybh"].ToString();
                }
                else
                    model.sjqybh = "";
                if (dr["sjqymc"] != null && dr["sjqymc"].ToString() != "")
                {
                    model.sjqymc = dr["sjqymc"].ToString();
                }
                else
                    model.sjqymc = "";
                if (dr["qybh"] != null && dr["qybh"].ToString() != "")
                {
                    model.qybh = dr["qybh"].ToString();
                }
                else
                    model.qybh = "";
                if (dr["qymc"] != null && dr["qymc"].ToString() != "")
                {
                    model.qymc = dr["qymc"].ToString();
                }
                else
                    model.qymc = "";
                if (dr["Dmfzr"] != null && dr["Dmfzr"].ToString() != "")
                {
                    model.Dmfzr = dr["Dmfzr"].ToString();
                }
                else
                    model.Dmfzr = "";
                if (dr["fzrsj"] != null && dr["fzrsj"].ToString() != "")
                {
                    model.fzrsj = dr["fzrsj"].ToString();
                }
                else
                    model.fzrsj = "";
                if (dr["Dmdh"] != null && dr["Dmdh"].ToString() != "")
                {
                    model.Dmdh = dr["Dmdh"].ToString();
                }
                else
                    model.Dmdh = "";
                if (dr["Dmdz"] != null && dr["Dmdz"].ToString() != "")
                {
                    model.Dmdz = dr["Dmdz"].ToString();
                }
                else
                    model.Dmdz = "";
                if (dr["Ljfhje"] != null && dr["Ljfhje"].ToString() != "")
                {
                    model.Ljfhje = decimal.Parse(dr["Ljfhje"].ToString());
                }
                else
                    model.Ljfhje = 0;
                if (dr["Yskye"] != null && dr["Yskye"].ToString() != "")
                {
                    model.Yskye = decimal.Parse(dr["Yskye"].ToString());
                }
                else
                    model.Yskye = 0;
                if (dr["zhdhrq"] != null && dr["zhdhrq"].ToString() != "")
                {
                    model.zhdhrq = DateTime.Parse(dr["zhdhrq"].ToString());
                }
                else
                    model.zhdhrq = Convert.ToDateTime("1901-01-01");
                if (dr["djyh"] != null && dr["djyh"].ToString() != "")
                {
                    model.djyh = dr["djyh"].ToString();
                }
                else
                    model.djyh = "";
                if (dr["djsj"] != null && dr["djsj"].ToString() != "")
                {
                    model.djsj = DateTime.Parse(dr["djsj"].ToString());
                }
                else
                    model.djsj = Convert.ToDateTime("1901-01-01");
                if (dr["xgyh"] != null && dr["xgyh"].ToString() != "")
                {
                    model.xgyh = dr["xgyh"].ToString();
                }
                else
                    model.xgyh = "";
                if (dr["xgsj"] != null && dr["xgsj"].ToString() != "")
                {
                    model.xgsj = DateTime.Parse(dr["xgsj"].ToString());
                }
                else
                    model.xgsj = Convert.ToDateTime("1901-01-01");
                if (dr["dmmj"] != null && dr["dmmj"].ToString() != "")
                {
                    model.dmmj = dr["dmmj"].ToString();
                }
                else
                    model.dmmj = "";
                if (dr["yq"] != null && dr["yq"].ToString() != "")
                {
                    model.yq = dr["yq"].ToString();
                }
                else
                    model.yq = "";
                if (dr["sq"] != null && dr["sq"].ToString() != "")
                {
                    model.sq = dr["sq"].ToString();
                }
                else
                    model.sq = "";
                if (dr["fz"] != null && dr["fz"].ToString() != "")
                {
                    model.fz = dr["fz"].ToString();
                }
                else
                    model.fz = "";

                if (dr["wsdhmm"] != null && dr["wsdhmm"].ToString() != "")
                {
                    model.wsdhmm = dr["wsdhmm"].ToString();
                }
                else
                    model.wsdhmm = "";
                if (dr["wzdlyxq"] != null && dr["wzdlyxq"].ToString() != "")
                {
                    model.wzdlyxq = dr["wzdlyxq"].ToString();
                }
                else
                    model.wzdlyxq = "";
                if (dr["zdffs"] != null && dr["zdffs"].ToString() != "")
                {
                    model.zdffs = int.Parse(dr["zdffs"].ToString());
                }
                else
                    model.zdffs = 0;
                if (dr["dmzk"] != null && dr["dmzk"].ToString() != "")
                {
                    model.dmzk = decimal.Parse(dr["dmzk"].ToString());
                }
                else
                    model.dmzk = 0;
                return model;
            }
            else
            {
                return null;
            }
        }
        public bool IsExistBmdaH(string bmdaH)
        {
            bool isExist = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  bmbh from dbo.bmdaH  where bmbh='" + bmdaH + "'");

            object obj = SQLHelper.GetSingle(strSql.ToString());
            if (obj != null && obj.ToString() != "")
            {
                isExist = true;
            }
            return isExist;
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool AddbmdaH(bmdaHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into bmdaH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,Bmbh,Bmmc)");
            strSql.Append(" values (");
            strSql.Append("@DjLsh,@DjBtZdh,@DjFtZdh,@DjStZdh,@DjState,@DjCount,@Bmbh,@Bmmc)");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@Bmbh", SqlDbType.VarChar,10),
                    new SqlParameter("@Bmmc", SqlDbType.VarChar,20)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.Bmbh;
            parameters[7].Value = model.Bmmc;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdatebmdaH(bmdaHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update bmdaH set ");
            strSql.Append("DjLsh=@DjLsh,");
            strSql.Append("DjBtZdh=@DjBtZdh,");
            strSql.Append("DjFtZdh=@DjFtZdh,");
            strSql.Append("DjStZdh=@DjStZdh,");
            strSql.Append("DjState=@DjState,");
            strSql.Append("DjCount=@DjCount,");
            //strSql.Append("Bmbh=@Bmbh,");
            strSql.Append("Bmmc=@Bmmc");
            strSql.Append(" where  Bmbh=@Bmbh ");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@Bmbh", SqlDbType.VarChar,10),
                    new SqlParameter("@Bmmc", SqlDbType.VarChar,20)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.Bmbh;
            parameters[7].Value = model.Bmmc;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public bmdaHModel GetbmdaHModel(DataRow dr)
        {
            if (dr != null)
            {
                bmdaHModel model = new bmdaHModel();
                if (dr["DjLsh"] != null && dr["DjLsh"].ToString() != "")
                {
                    model.DjLsh = int.Parse(dr["DjLsh"].ToString());
                }
                if (dr["DjBtZdh"] != null && dr["DjBtZdh"].ToString() != "")
                {
                    model.DjBtZdh = int.Parse(dr["DjBtZdh"].ToString());
                }
                if (dr["DjFtZdh"] != null && dr["DjFtZdh"].ToString() != "")
                {
                    model.DjFtZdh = int.Parse(dr["DjFtZdh"].ToString());
                }
                if (dr["DjStZdh"] != null && dr["DjStZdh"].ToString() != "")
                {
                    model.DjStZdh = int.Parse(dr["DjStZdh"].ToString());
                }
                if (dr["DjState"] != null && dr["DjState"].ToString() != "")
                {
                    model.DjState = dr["DjState"].ToString();
                }
                else
                    model.DjState = "";
                if (dr["DjCount"] != null && dr["DjCount"].ToString() != "")
                {
                    model.DjCount = int.Parse(dr["DjCount"].ToString());
                }
                else
                    model.DjCount = 0;
                if (dr["Bmbh"] != null && dr["Bmbh"].ToString() != "")
                {
                    model.Bmbh = dr["Bmbh"].ToString();
                }
                else
                    model.Bmbh = "";
                if (dr["Bmmc"] != null && dr["Bmmc"].ToString() != "")
                {
                    model.Bmmc = dr["Bmmc"].ToString();
                }
                else
                    model.Bmmc = "";
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 是否存在 店面信息
        /// </summary>
        /// <param name="spbh"></param>
        /// <returns></returns>
        public bool IsExistDmxx(string dmbh)
        {
            bool isExist = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  dmbh from dbo.dmdaH  where dmbh='" + dmbh + "'");

            object obj = SQLHelper.GetSingle(strSql.ToString());
            if (obj != null && obj.ToString() != "")
            {
                isExist = true;
            }
            return isExist;
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool AdddmdaH(dmdaHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dmdaH(");
            strSql.Append("DjLsh,DjBtZdh,DjFtZdh,DjStZdh,DjState,DjCount,Dmbh,Dmmc,Dmlb,sjqybh,sjqymc,qybh,qymc,Dmfzr,fzrsj,Dmdh,Dmdz,Ljfhje,Yskye,zhdhrq,djyh,djsj,xgyh,xgsj,dmmj,yq,sq,fz,wsdhmm,wzdlyxq,zdffs,dmzk)");
            strSql.Append(" values (");
            strSql.Append("@DjLsh,@DjBtZdh,@DjFtZdh,@DjStZdh,@DjState,@DjCount,@Dmbh,@Dmmc,@Dmlb,@sjqybh,@sjqymc,@qybh,@qymc,@Dmfzr,@fzrsj,@Dmdh,@Dmdz,@Ljfhje,@Yskye,@zhdhrq,@djyh,@djsj,@xgyh,@xgsj,@dmmj,@yq,@sq,@fz,@wsdhmm,@wzdlyxq,@zdffs,@dmzk)");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@Dmbh", SqlDbType.VarChar,10),
                    new SqlParameter("@Dmmc", SqlDbType.VarChar,20),
                    new SqlParameter("@Dmlb", SqlDbType.VarChar,20),
                    new SqlParameter("@sjqybh", SqlDbType.VarChar,10),
                    new SqlParameter("@sjqymc", SqlDbType.VarChar,20),
                    new SqlParameter("@qybh", SqlDbType.VarChar,20),
                    new SqlParameter("@qymc", SqlDbType.VarChar,20),
                    new SqlParameter("@Dmfzr", SqlDbType.VarChar,20),
                    new SqlParameter("@fzrsj", SqlDbType.VarChar,20),
                    new SqlParameter("@Dmdh", SqlDbType.VarChar,20),
                    new SqlParameter("@Dmdz", SqlDbType.VarChar,100),
                    new SqlParameter("@Ljfhje", SqlDbType.Money,8),
                    new SqlParameter("@Yskye", SqlDbType.Money,8),
                    new SqlParameter("@zhdhrq", SqlDbType.DateTime),
                    new SqlParameter("@djyh", SqlDbType.VarChar,10),
                    new SqlParameter("@djsj", SqlDbType.DateTime),
                    new SqlParameter("@xgyh", SqlDbType.VarChar,10),
                    new SqlParameter("@xgsj", SqlDbType.DateTime),
                    new SqlParameter("@dmmj", SqlDbType.VarChar,15),
                    new SqlParameter("@yq", SqlDbType.VarChar,10),
                    new SqlParameter("@sq", SqlDbType.VarChar,10),
                    new SqlParameter("@fz", SqlDbType.VarChar,10),
                    new SqlParameter("@wsdhmm", SqlDbType.VarChar,20),
                    new SqlParameter("@wzdlyxq", SqlDbType.VarChar,10),
                    new SqlParameter("@zdffs", SqlDbType.Int,4),
                    new SqlParameter("@dmzk", SqlDbType.Decimal,9)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.Dmbh;
            parameters[7].Value = model.Dmmc;
            parameters[8].Value = model.Dmlb;
            parameters[9].Value = model.sjqybh;
            parameters[10].Value = model.sjqymc;
            parameters[11].Value = model.qybh;
            parameters[12].Value = model.qymc;
            parameters[13].Value = model.Dmfzr;
            parameters[14].Value = model.fzrsj;
            parameters[15].Value = model.Dmdh;
            parameters[16].Value = model.Dmdz;
            parameters[17].Value = model.Ljfhje;
            parameters[18].Value = model.Yskye;
            parameters[19].Value = model.zhdhrq;
            parameters[20].Value = model.djyh;
            parameters[21].Value = model.djsj;
            parameters[22].Value = model.xgyh;
            parameters[23].Value = model.xgsj;
            parameters[24].Value = model.dmmj;
            parameters[25].Value = model.yq;
            parameters[26].Value = model.sq;
            parameters[27].Value = model.fz;
            parameters[28].Value = model.wsdhmm;
            parameters[29].Value = model.wzdlyxq;
            parameters[30].Value = model.zdffs;
            parameters[31].Value = model.dmzk;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool UpdatedmdaH(dmdaHModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update dmdaH set ");
            strSql.Append("DjLsh=@DjLsh,");
            strSql.Append("DjBtZdh=@DjBtZdh,");
            strSql.Append("DjFtZdh=@DjFtZdh,");
            strSql.Append("DjStZdh=@DjStZdh,");
            strSql.Append("DjState=@DjState,");
            strSql.Append("DjCount=@DjCount,");
            //strSql.Append("Dmbh=@Dmbh,");
            strSql.Append("Dmmc=@Dmmc,");
            strSql.Append("Dmlb=@Dmlb,");
            strSql.Append("sjqybh=@sjqybh,");
            strSql.Append("sjqymc=@sjqymc,");
            strSql.Append("qybh=@qybh,");
            strSql.Append("qymc=@qymc,");
            strSql.Append("Dmfzr=@Dmfzr,");
            strSql.Append("fzrsj=@fzrsj,");
            strSql.Append("Dmdh=@Dmdh,");
            strSql.Append("Dmdz=@Dmdz,");
            strSql.Append("Ljfhje=@Ljfhje,");
            strSql.Append("Yskye=@Yskye,");
            strSql.Append("zhdhrq=@zhdhrq,");
            strSql.Append("djyh=@djyh,");
            strSql.Append("djsj=@djsj,");
            strSql.Append("xgyh=@xgyh,");
            strSql.Append("xgsj=@xgsj,");
            strSql.Append("dmmj=@dmmj,");
            strSql.Append("yq=@yq,");
            strSql.Append("sq=@sq,");
            strSql.Append("fz=@fz,");
            strSql.Append("wsdhmm=@wsdhmm,");
            strSql.Append("wzdlyxq=@wzdlyxq,");
            strSql.Append("zdffs=@zdffs,");
            strSql.Append("dmzk=@dmzk");
            strSql.Append(" where  Dmbh=@Dmbh ");
            SqlParameter[] parameters = {
                    new SqlParameter("@DjLsh", SqlDbType.Int,4),
                    new SqlParameter("@DjBtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjFtZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjStZdh", SqlDbType.Int,4),
                    new SqlParameter("@DjState", SqlDbType.Char,4),
                    new SqlParameter("@DjCount", SqlDbType.Int,4),
                    new SqlParameter("@Dmbh", SqlDbType.VarChar,10),
                    new SqlParameter("@Dmmc", SqlDbType.VarChar,20),
                    new SqlParameter("@Dmlb", SqlDbType.VarChar,20),
                    new SqlParameter("@sjqybh", SqlDbType.VarChar,10),
                    new SqlParameter("@sjqymc", SqlDbType.VarChar,20),
                    new SqlParameter("@qybh", SqlDbType.VarChar,20),
                    new SqlParameter("@qymc", SqlDbType.VarChar,20),
                    new SqlParameter("@Dmfzr", SqlDbType.VarChar,20),
                    new SqlParameter("@fzrsj", SqlDbType.VarChar,20),
                    new SqlParameter("@Dmdh", SqlDbType.VarChar,20),
                    new SqlParameter("@Dmdz", SqlDbType.VarChar,100),
                    new SqlParameter("@Ljfhje", SqlDbType.Money,8),
                    new SqlParameter("@Yskye", SqlDbType.Money,8),
                    new SqlParameter("@zhdhrq", SqlDbType.DateTime),
                    new SqlParameter("@djyh", SqlDbType.VarChar,10),
                    new SqlParameter("@djsj", SqlDbType.DateTime),
                    new SqlParameter("@xgyh", SqlDbType.VarChar,10),
                    new SqlParameter("@xgsj", SqlDbType.DateTime),
                    new SqlParameter("@dmmj", SqlDbType.VarChar,15),
                    new SqlParameter("@yq", SqlDbType.VarChar,10),
                    new SqlParameter("@sq", SqlDbType.VarChar,10),
                    new SqlParameter("@fz", SqlDbType.VarChar,10),
                    new SqlParameter("@wsdhmm", SqlDbType.VarChar,20),
                    new SqlParameter("@wzdlyxq", SqlDbType.VarChar,10),
                    new SqlParameter("@zdffs", SqlDbType.Int,4),
                    new SqlParameter("@dmzk", SqlDbType.Decimal,9)};
            parameters[0].Value = model.DjLsh;
            parameters[1].Value = model.DjBtZdh;
            parameters[2].Value = model.DjFtZdh;
            parameters[3].Value = model.DjStZdh;
            parameters[4].Value = model.DjState;
            parameters[5].Value = model.DjCount;
            parameters[6].Value = model.Dmbh;
            parameters[7].Value = model.Dmmc;
            parameters[8].Value = model.Dmlb;
            parameters[9].Value = model.sjqybh;
            parameters[10].Value = model.sjqymc;
            parameters[11].Value = model.qybh;
            parameters[12].Value = model.qymc;
            parameters[13].Value = model.Dmfzr;
            parameters[14].Value = model.fzrsj;
            parameters[15].Value = model.Dmdh;
            parameters[16].Value = model.Dmdz;
            parameters[17].Value = model.Ljfhje;
            parameters[18].Value = model.Yskye;
            parameters[19].Value = model.zhdhrq;
            parameters[20].Value = model.djyh;
            parameters[21].Value = model.djsj;
            parameters[22].Value = model.xgyh;
            parameters[23].Value = model.xgsj;
            parameters[24].Value = model.dmmj;
            parameters[25].Value = model.yq;
            parameters[26].Value = model.sq;
            parameters[27].Value = model.fz;
            parameters[28].Value = model.wsdhmm;
            parameters[29].Value = model.wzdlyxq;
            parameters[30].Value = model.zdffs;
            parameters[31].Value = model.dmzk;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        public void m_CreateErrorLogTxt(string strFunctionName, string strErrorNum, string strErrorDescription)
        {
            string strMatter; //错误内容
            string strPath; //错误文件的路径
            DateTime dt = DateTime.Now;
            try
            {
                //Server.MapPath("./") + "File"; 服务器端路径
                strPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\ErrorLog";
                // strPath = Directory.GetDirectoryRoot() + "\\ErrorLog";   //winform工程\bin\目录下 创建日志文件夹 
                //strPath = "c:" + "\\ErrorLog";//暂时放在c:下

                if (Directory.Exists(strPath) == false)  //工程目录下 Log目录 '目录是否存在,为true则没有此目录
                {
                    Directory.CreateDirectory(strPath); //建立目录　Directory为目录对象
                }
                strPath = strPath + "\\" + dt.ToString("yyyyMM");

                if (Directory.Exists(strPath) == false)  //目录是否存在  '工程目录下 Log\月 目录   yyyymm
                {
                    Directory.CreateDirectory(strPath);  //建立目录//日志文件，以 日 命名 
                }
                strPath = strPath + "\\" + dt.ToString("dd") + ".txt";

                strMatter = strFunctionName + " , " + strErrorNum + " , " + strErrorDescription;//生成错误信息

                StreamWriter FileWriter = new StreamWriter(strPath, true); //创建日志文件
                FileWriter.WriteLine("Time: " + dt.ToString("HH:mm:ss") + "  Err: " + strMatter);
                FileWriter.Close(); //关闭StreamWriter对象
            }
            catch (Exception ex)
            {

                string str = ex.Message.ToString();
            }
        }

    }
}
